#include <cstdio>
#include <set>

typedef long long ll;
int n, q, k;
ll ans;
std::multiset<int> set;

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("pancake.in", "r", stdin);
  freopen("pancake.out", "w", stdout);
#endif
#endif

  scanf("%d%d%d", &n, &q, &k);
  int tmp, opt;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &tmp);
    ans += 1ll * tmp * tmp;
    set.insert(-tmp);
  }
  for (int i = 1; i <= k; ++i) {
    tmp = -(*set.begin());
    ans -= 1ll * (tmp) * (tmp);
    ans += 1ll * (tmp / 2) * (tmp / 2) + 1ll * (tmp - tmp / 2) * (tmp - tmp / 2);
    set.erase(set.begin());
    set.insert(-(tmp >> 1)), set.insert(-(tmp - (tmp >> 1)));
  }
  printf("%lld\n", ans);
  while (q--) {
    scanf("%d", &opt);
    switch (opt) {
      case 1:
        tmp = -(*set.begin());
        ans -= 1ll * (tmp) * (tmp);
        ans += 1ll * (tmp / 2) * (tmp / 2) + 1ll * (tmp - tmp / 2) * (tmp - tmp / 2);
        set.erase(set.begin());
        set.insert(-(tmp >> 1)), set.insert(-(tmp - (tmp >> 1)));
        printf("%lld\n", ans);
        break;
    }
  }
  return 0;
}